package thread;

class MyThread extends Thread{
    //run相当于线程的入口
    @Override
    public void run(){
        while(true){
            System.out.println("Hello thread");
            //sleep 是 thread 的静态方法
            try {
                Thread.sleep(1000);//毫秒
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread=new MyThread();
        //真正在系统中创建一个线程
       myThread.start();
        //myThread.run();
        while(true){
            System.out.println("Hello main");
            Thread.sleep(1000);
        }
    }
}
